//
//  YZPublishCommunityVideoCell.m
//  VET
//
//  Created by YZ on 2018/7/16.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZPublishCommunityVideoCell.h"

@interface YZPublishCommunityVideoCell()

@property (nonatomic, strong) UIImageView *imgView;

@property (nonatomic, strong) UIImageView *pauseImgView;

@end

@implementation YZPublishCommunityVideoCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        self.layer.masksToBounds = YES;
        [self.contentView addSubview:self.imgView];
        [self.contentView addSubview:self.pauseImgView];
        
        [self makeContraints];
    }
    return self;
}

- (void)makeContraints
{
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsZero);
    }];
    
    [self.pauseImgView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(kCurrentDeviceNum(30), kCurrentDeviceNum(30)));
    }];
}

#pragma mark -- setters && getters

- (UIImageView *)imgView
{
    if(!_imgView){
        _imgView = [UIImageView new];
    }
    return _imgView;
}

- (UIImageView *)pauseImgView
{
    if(!_pauseImgView){
        _pauseImgView = [UIImageView new];
        _pauseImgView.image = [UIImage imageNamed:@"ico_video_32"];
    }
    return _pauseImgView;
}

- (void)setModel:(YZPublishCommunityVideoModel *)model
{
    _model = model;
    [RACObserve(model, img) subscribeNext:^(id  _Nullable x) {
        if (x) {
            self.imgView.image = (UIImage *)x;
        }
    }];
}

@end
